

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/fluid.png">
  <link rel="icon" href="/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="ShanCe">
  <meta name="keywords" content="">
  
    <meta name="description" content="前言除了之前集成的flower或者django-clery-result, django-celery-beat之外，可能需要我们自己在项目中集成，所以记录一些可能会使用的方法，不断完善 获取所有正在运行的任务1234567from celery import current_appinspect &#x3D; current_app.control.inspect([])# 获取所有的任务active_t">
<meta property="og:type" content="article">
<meta property="og:title" content="2.celery方法">
<meta property="og:url" content="https://sweetshance.github.io/2024/06/18/celery+django%E6%90%AD%E5%BB%BA%E5%AD%A6%E4%B9%A0/2-celery%E6%96%B9%E6%B3%95/index.html">
<meta property="og:site_name" content="ShanCe的博客">
<meta property="og:description" content="前言除了之前集成的flower或者django-clery-result, django-celery-beat之外，可能需要我们自己在项目中集成，所以记录一些可能会使用的方法，不断完善 获取所有正在运行的任务1234567from celery import current_appinspect &#x3D; current_app.control.inspect([])# 获取所有的任务active_t">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2024-06-18T07:45:45.000Z">
<meta property="article:modified_time" content="2024-06-19T06:15:36.811Z">
<meta property="article:author" content="ShanCe">
<meta name="twitter:card" content="summary_large_image">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>2.celery方法 - ShanCe的博客</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"sweetshance.github.io","root":"/","version":"1.9.4","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 5.4.2"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>ShanCe</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                <span>首页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                <span>归档</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                <span>标签</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                <span>关于</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="2.celery方法"></span>
          
        </div>

        
          
  <div class="mt-3">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-author" aria-hidden="true"></i>
        ShanCe
      </span>
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2024-06-18 15:45" pubdate>
          2024年6月18日 下午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          2.9k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          24 分钟
        
      </span>
    

    
    
      
        <span id="busuanzi_container_page_pv" style="display: none">
          <i class="iconfont icon-eye" aria-hidden="true"></i>
          <span id="busuanzi_value_page_pv"></span> 次
        </span>
        
      
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">2.celery方法</h1>
            
            
              <div class="markdown-body">
                
                <h3 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h3><p>除了之前集成的flower或者django-clery-result, django-celery-beat之外，可能需要我们自己在项目中集成，所以记录一些可能会使用的方法，不断完善</p>
<h3 id="获取所有正在运行的任务"><a href="#获取所有正在运行的任务" class="headerlink" title="获取所有正在运行的任务"></a>获取所有正在运行的任务</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-keyword">from</span> celery <span class="hljs-keyword">import</span> current_app<br>inspect = current_app.control.inspect([])<br><span class="hljs-comment"># 获取所有的任务</span><br>active_tasks = inspect.active()<br>reserved_tasks = inspect.reserved()<br><span class="hljs-built_in">print</span>(active_tasks)<br><span class="hljs-built_in">print</span>(reserved_tasks)<br></code></pre></td></tr></table></figure>

<p>结果:</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><code class="hljs python">&#123;<span class="hljs-string">&#x27;celery@MININT-IBMA8LV&#x27;</span>: [<br>    &#123;<br>        <span class="hljs-comment"># 任务id</span><br>        <span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-string">&#x27;f18ae0a5-b731-4ec0-9ae9-22de86555f26&#x27;</span>, <br>        <span class="hljs-string">&#x27;name&#x27;</span>: <span class="hljs-string">&#x27;celeryd.tasks.add&#x27;</span>, <br>        <span class="hljs-string">&#x27;args&#x27;</span>: [<span class="hljs-number">10</span>, <span class="hljs-number">11</span>], <br>        <span class="hljs-string">&#x27;kwargs&#x27;</span>: &#123;&#125;, <br>        <span class="hljs-string">&#x27;type&#x27;</span>: <span class="hljs-string">&#x27;celeryd.tasks.add&#x27;</span>, <br>        <span class="hljs-string">&#x27;hostname&#x27;</span>: <span class="hljs-string">&#x27;celery@MININT-IBMA8LV&#x27;</span>, <br>        <span class="hljs-string">&#x27;time_start&#x27;</span>: <span class="hljs-number">1718696887.0314705</span>, <br>        <span class="hljs-string">&#x27;acknowledged&#x27;</span>: <span class="hljs-literal">True</span>, <br>        <span class="hljs-string">&#x27;delivery_info&#x27;</span>: <br>            &#123;<br>                <span class="hljs-string">&#x27;exchange&#x27;</span>: <span class="hljs-string">&#x27;&#x27;</span>, <br>                <span class="hljs-string">&#x27;routing_key&#x27;</span>: <span class="hljs-string">&#x27;celery&#x27;</span>, <br>                <span class="hljs-string">&#x27;priority&#x27;</span>: <span class="hljs-number">0</span>, <br>                <span class="hljs-string">&#x27;redelivered&#x27;</span>: <span class="hljs-literal">None</span><br>            &#125;, <br>            <span class="hljs-string">&#x27;worker_pid&#x27;</span>: <span class="hljs-number">2417361519752</span>&#125;]&#125;<br>[]<br></code></pre></td></tr></table></figure>
<p>这个只会获取到正在运行的，如果没有返回 [] 列表</p>
<h3 id="终止正在运行的任务"><a href="#终止正在运行的任务" class="headerlink" title="终止正在运行的任务"></a>终止正在运行的任务</h3><h4 id="异步任务"><a href="#异步任务" class="headerlink" title="异步任务"></a>异步任务</h4><ol>
<li>获取任务id<br>在使用异步任务的地方获取任务id存起来，然后根据id去停止<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs python">task = add.delay(<span class="hljs-number">10</span>, <span class="hljs-number">11</span>)<br>task_id = task.<span class="hljs-built_in">id</span><br></code></pre></td></tr></table></figure></li>
<li>停止指定任务id<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-keyword">from</span> celeryAbout.celeryd <span class="hljs-keyword">import</span> app<br><span class="hljs-comment"># app是我项目中的celery对象</span><br><span class="hljs-comment"># d97d894e-64e4-4348-86cf-1dcef3c40b5c 就是正在执行的任务的id</span><br>app.control.revoke(<span class="hljs-string">&#x27;d97d894e-64e4-4348-86cf-1dcef3c40b5c&#x27;</span>, terminate=<span class="hljs-literal">True</span>)<br></code></pre></td></tr></table></figure></li>
</ol>
<h4 id="定时任务"><a href="#定时任务" class="headerlink" title="定时任务"></a>定时任务</h4><ol>
<li>定时任务可以在任务里获取任务id存储<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-comment"># bind 绑定上下文</span><br><span class="hljs-meta">@app.task(<span class="hljs-params">track_started=<span class="hljs-literal">True</span>, bind=<span class="hljs-literal">True</span></span>)</span><br><span class="hljs-keyword">def</span> <span class="hljs-title function_">test</span>(<span class="hljs-params">self</span>):<br>    <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">50</span>):<br>        <span class="hljs-comment"># 获取任务id</span><br>        <span class="hljs-built_in">print</span>(self.request.<span class="hljs-built_in">id</span>)<br>        time.sleep(<span class="hljs-number">1</span>)<br>        <span class="hljs-built_in">print</span>(i)<br>    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;task worker ===============&quot;</span>)<br></code></pre></td></tr></table></figure></li>
<li>停止方法和上边一样</li>
</ol>
<h3 id="任务失败重试"><a href="#任务失败重试" class="headerlink" title="任务失败重试"></a>任务失败重试</h3><p>task 示例：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-keyword">from</span> celery <span class="hljs-keyword">import</span> shared_task<br><br><br><span class="hljs-meta">@shared_task(<span class="hljs-params">bind=<span class="hljs-literal">True</span></span>)</span><br><span class="hljs-keyword">def</span> <span class="hljs-title function_">add</span>(<span class="hljs-params">self, a: <span class="hljs-built_in">int</span>, b: <span class="hljs-built_in">int</span></span>):<br>    <span class="hljs-keyword">try</span>:<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;执行异步&quot;</span>)<br>        <span class="hljs-keyword">raise</span> Exception<br>    <span class="hljs-keyword">except</span> Exception <span class="hljs-keyword">as</span> e:<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;出错重试xxxxxxxxxxxxxxxxxxx&quot;</span>)<br>        <span class="hljs-comment"># countdown 重试间隔时间，max_retries 最大重试次数</span><br>        self.retry(exc=e, countdown=<span class="hljs-number">4</span>, max_retries=<span class="hljs-number">4</span>)<br>    <span class="hljs-keyword">return</span> a + b<br></code></pre></td></tr></table></figure>
<p>self 是celery.app.task.Task的实例，可以用于实现重试等多种功能</p>
<h3 id="任务钩子函数"><a href="#任务钩子函数" class="headerlink" title="任务钩子函数"></a>任务钩子函数</h3><p>可以理解为，celery提供了，在不同状态下默认执行的方法</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-keyword">from</span> celery <span class="hljs-keyword">import</span> Task<br><span class="hljs-keyword">from</span> celery <span class="hljs-keyword">import</span> shared_task<br> <br><br><span class="hljs-comment"># 钩子函数</span><br><span class="hljs-keyword">class</span> <span class="hljs-title class_">MyHookTask</span>(<span class="hljs-title class_ inherited__">Task</span>):<br> <br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">on_success</span>(<span class="hljs-params">self, retval, task_id, args, kwargs</span>):<br>        <span class="hljs-comment"># 成功的时候执行的方法</span><br>        logger.info(<span class="hljs-string">f&#x27;task id:<span class="hljs-subst">&#123;task_id&#125;</span> , arg:<span class="hljs-subst">&#123;args&#125;</span> , successful !&#x27;</span>)<br> <br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">on_failure</span>(<span class="hljs-params">self, exc, task_id, args, kwargs, einfo</span>):<br>        <span class="hljs-comment"># 失败的时候执行的方法</span><br>        logger.info(<span class="hljs-string">f&#x27;task id:<span class="hljs-subst">&#123;task_id&#125;</span> , arg:<span class="hljs-subst">&#123;args&#125;</span> , failed ! erros: <span class="hljs-subst">&#123;exc&#125;</span>&#x27;</span>)<br> <br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">on_retry</span>(<span class="hljs-params">self, exc, task_id, args, kwargs, einfo</span>):<br>        <span class="hljs-comment"># 重试的时候执行的方法</span><br>        logger.info(<span class="hljs-string">f&#x27;task id:<span class="hljs-subst">&#123;task_id&#125;</span> , arg:<span class="hljs-subst">&#123;args&#125;</span> , retry !  erros: <span class="hljs-subst">&#123;exc&#125;</span>&#x27;</span>)<br> <br> <br> <br> <br><span class="hljs-comment"># 在对应的task函数的装饰器中，通过 base=MyHookTask 指定钩子方法</span><br><span class="hljs-meta">@shared_task(<span class="hljs-params">base=MyHookTask, bind=<span class="hljs-literal">True</span></span>)</span><br><span class="hljs-keyword">def</span> <span class="hljs-title function_">add</span>(<span class="hljs-params">self,x, y</span>):<br>    logger.info(<span class="hljs-string">&#x27;add__-----&#x27;</span>*<span class="hljs-number">10</span>)<br>    logger.info(<span class="hljs-string">&#x27;name:&#x27;</span>,self.name)<br>    logger.info(<span class="hljs-string">&#x27;dir(self)&#x27;</span>,<span class="hljs-built_in">dir</span>(self))<br>    <span class="hljs-keyword">return</span> x + y<br></code></pre></td></tr></table></figure>

<h3 id="动态增加、删除、暂停、恢复定时任务"><a href="#动态增加、删除、暂停、恢复定时任务" class="headerlink" title="动态增加、删除、暂停、恢复定时任务"></a>动态增加、删除、暂停、恢复定时任务</h3><ol>
<li><p>使用django-celery-beat 结合django-admin进行配置<br><a target="_blank" rel="noopener" href="https://www.cnblogs.com/huangxiaoxue/p/7266253.html">https://www.cnblogs.com/huangxiaoxue/p/7266253.html</a></p>
</li>
<li><p>falsk 大佬写的方法<br><a target="_blank" rel="noopener" href="https://blog.csdn.net/yannanxiu/article/details/85543684">https://blog.csdn.net/yannanxiu/article/details/85543684</a><br>注意：目前没有找到直接操作celery的方法，看文档中说，需要任务调度将 数据库中的任务配置推送到 celery-beat 中，接着研究。</p>
</li>
</ol>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>2.celery方法</div>
      <div>https://sweetshance.github.io/2024/06/18/celery+django搭建学习/2-celery方法/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>ShanCe</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2024年6月18日</div>
        </div>
      
      
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2024/08/08/springBoot%E5%AD%A6%E4%B9%A0/springBoot-mybatis%E5%A4%9A%E6%95%B0%E6%8D%AE%E6%BA%90%E5%92%8C%E4%BA%8B%E5%8A%A1/" title="springBoot+mybatis多数据源和事务">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">springBoot+mybatis多数据源和事务</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2024/06/18/web%E7%9F%A5%E8%AF%86/vue%E4%BD%BF%E7%94%A8proxyTable%E5%8A%A0axios%E5%AE%9E%E7%8E%B0%E5%90%8E%E7%AB%AF%E5%9C%B0%E5%9D%80%E8%87%AA%E5%8A%A8%E6%8B%BC%E6%8E%A5/" title="vue使用proxyTable加axios实现后端地址自动拼接">
                        <span class="hidden-mobile">vue使用proxyTable加axios实现后端地址自动拼接</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="http://82.157.172.231/" target="_blank" rel="nofollow noopener"><span>无聊</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>ShanCe</span></a> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
